#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
map<pair<int, int>, bool> vis;
map<pair<int, int>, pair<int, int>> reach;
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int d1 = ceil(abs(x) / (double)n);
		int d2 = ceil(abs(y) / (double)m);
		int ed1 = (x + d1 * n) % n;
		int ed2 = (y + d2 * m) % m;
		if (vis[{x, y}])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[{ed1, ed2}]) {
			vis[{x, y}] = 1;
			vis[{ed1, ed2}] = 1;
			reach[{ed1, ed2}] = { x, y };
			dfs(x, y);
		}
		else {
			vis[{x, y}] = 1;
			if (make_pair(x, y) != reach[{ed1, ed2}]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[{s1, s2}] = 1;
	reach[{s1, s2}] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
map<pair<int, int>, bool> vis;
bool ok;
int s1, s2;
bool valid(int i, int j) {
	int x = (i + n) % n;
	int y = (j + m) % m;
	if (grid[x][y] == '#')
		return 0;
	if (vis[{i, j}])
		return 0;
	return 1;
}
void dfs(int i, int j) {
	vis[{i, j}] = 1;
	int x = (i + n) % n;
	int y = (j + m) % m;
	if (((x != i) || (y != j)) && (vis[{x, y}])) {
		ok = 1;
		return;
	}
	for (int r = 0; r < 4; r++) {
		x = i + dx[r];
		y = j + dy[r];
		if (valid(x, y)) {
			dfs(x, y);
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 2000 + 2;
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
bool vis[10000][10000];
pair<int, int> reach[N][N];
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (vis[x + N][y + N])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[ed1][ed2]) {
			vis[x + N][y + N] = 1;
			vis[ed1][ed2] = 1;
			reach[ed1][ed2] = { x, y };
			dfs(x, y);
		}
		else {
			if (make_pair(x, y) != reach[ed1][ed2]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[s1 + N][s2 + N] = 1;
	reach[s1][s2] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 2000 + 2;
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
bool vis[13000][13000];
pair<int, int> reach[N][N];
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (vis[x + N][y + N])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[ed1][ed2]) {
			vis[x + N][y + N] = 1;
			vis[ed1][ed2] = 1;
			reach[ed1][ed2] = { x, y };
			dfs(x, y);
		}
		else {
			if (make_pair(x, y) != reach[ed1][ed2]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[s1 + N][s2 + N] = 1;
	reach[s1][s2] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 1509;
char grid[N][N];
int n, m;
bool valid(int i, int j) {
	if (i >= n && j >= m)
		return 0;
	if (i >= n && j < 0)
		return 0;
	if (i < 0 && j >= n)
		return 0;
	if (i < 0 && j < 0)
		return 0;
	if (grid[abs(i) % n][abs(j) % m] != '#')
		return 1;
	return 0;
}
bool ok = 0;
map<pair<int, int>, bool>vis;
void fill(int i, int j) {
	if (abs(i) == 2 * n || abs(j) == 2 * m) {
		ok = 1;
		return;
	}
	if (vis[{i, j}])
		return;
	vis[{i, j}] = 1;
	int x, y;
	for (int r = 0; r < 4; r++) {
		x = dx[r] + i;
		y = dy[r] + j;
		if (valid(x, y))
			fill(x, y);
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	int s1, s2;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i, s2 = j;
				grid[i][j] = '.';
			}
		}
	}
	fill(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 1500 + 2;
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
bool vis[N][N];
pair<int, int> reach[N][N];
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[ed1][ed2]) {
			vis[ed1][ed2] = 1;
			reach[ed1][ed2] = { x, y };
			dfs(x, y);
		}
		else {
			if (make_pair(x, y) != reach[ed1][ed2]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[s1][s2] = 1;
	reach[s1][s2] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
map<pair<int, int>, bool> vis;
map<pair<int, int>, pair<int, int>> reach;
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int d1 = (abs(x) + n - 1) / n;
		int d2 = (abs(y) + m - 1) / m;
		int ed1 = (x + d1 * n) % n;
		int ed2 = (y + d2 * m) % m;
		if (vis[{x, y}])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[{ed1, ed2}]) {
			vis[{x, y}] = 1;
			vis[{ed1, ed2}] = 1;
			reach[{ed1, ed2}] = { x, y };
			dfs(x, y);
		}
		else {
			vis[{x, y}] = 1;
			if (make_pair(x, y) != reach[{ed1, ed2}]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[{s1, s2}] = 1;
	reach[{s1, s2}] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
map<pair<int, int>, bool> vis;
bool ok;
int s1, s2;
void dfs(int i, int j, int take) {
	vis[{i, j}] = 1;
	int no = -4;
	if (take == 0)
		no = 1;
	if (take == 1)
		no = 0;
	if (take == 2)
		no = 3;
	if (take == 3)
		no = 2;
	for (int r = 0; r < 4; r++) {
		if (r == no)
			continue;
		int x = i + dx[r];
		int y = j + dy[r];
		x = (x + n) % n;
		y = (y + m) % m;
		if (grid[x][y] == '#')
			continue;
		if (vis[{x, y}]) {
			ok = 1;
			return;
		}
		dfs(x, y, r);
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}

	dfs(s1, s2, -1);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
map<pair<int, int>, set<pair<int, int>>> vis;
bool ok;
int s1, s2;
bool valid(int i, int j) {
	int x = (i + n) % n;
	int y = (j + m) % m;
	if (grid[x][y] == '#')
		return 0;
	return 1;
}
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		if (!valid(x, y))
			continue;
		int ed1 = (x + n) % n;
		int ed2 = (y + m) % m;
		int sz = vis[{ed1, ed2}].size();
		vis[{ed1, ed2}].insert({ x, y });
		if (vis[{ed1, ed2}].size() == 2) {
			ok = 1;
			return;
		}
		if (sz != vis[{ed1, ed2}].size()) {
			dfs(x, y);
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
map<pair<int, int>, bool> vis;
map<pair<int, int>, pair<int, int>> reach;
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (vis[{x, y}])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (vis[{ed1, ed2}] && reach[{ed1, ed2}] == make_pair(x, y))
			continue;
		if (!vis[{ed1, ed2}]) {
			vis[{x, y}] = 1;
			vis[{ed1, ed2}] = 1;
			reach[{ed1, ed2}] = { x, y };
			dfs(x, y);
		}
		else {
			if (make_pair(x, y) != reach[{ed1, ed2}]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[{s1, s2}] = 1;
	reach[{s1, s2}] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 1509;
char grid[N][N];
int n, m;
bool valid(int i, int j) {
	if (grid[abs(i) % n][abs(j) % m] != '#')
		return 1;
	return 0;
}
bool ok = 0;
map<pair<int, int>, bool>vis;
void fill(int i, int j) {
	if (abs(i) == 2 * n || abs(j) == 2 * m) {
		ok = 1;
		return;
	}
	if (vis[{i, j}])
		return;
	vis[{i, j}] = 1;
	int x, y;
	for (int r = 0; r < 4; r++) {
		x = dx[r] + i;
		y = dy[r] + j;
		if (valid(x, y))
			fill(x, y);
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	int s1, s2;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i, s2 = j;
				grid[i][j] = '.';
			}
		}
	}
	fill(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 3000 + 2;
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
bool vis[10000][10000];
pair<int, int> reach[N][N];
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (vis[x + N][y + N])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[ed1][ed2]) {
			vis[x + N][y + N] = 1;
			vis[ed1][ed2] = 1;
			reach[ed1][ed2] = { x, y };
			dfs(x, y);
		}
		else {
			if (make_pair(x, y) != reach[ed1][ed2]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[s1 + N][s2 + N] = 1;
	reach[s1][s2] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 1500 + 2;
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
map<pair<int, int>, bool >vis;
pair<int, int> reach[N][N];
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (vis[{x, y}])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[{ed1, ed2}]) {
			vis[{x, y}] = 1;
			vis[{ed1, ed2}] = 1;
			reach[ed1][ed2] = { x, y };
			dfs(x, y);
		}
		else {
			if (make_pair(x, y) != reach[ed1][ed2]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[{s1, s2}] = 1;
	reach[s1][s2] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
map<pair<int, int>, bool> vis;
map<pair<int, int>, pair<int, int>> reach;
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = (x + n) % n;
		int ed2 = (y + m) %m;
		if (vis[{x, y}])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[{ed1, ed2}]) {
			vis[{x, y}] = 1;
			vis[{ed1, ed2}] = 1;
			reach[{ed1, ed2}] = {i, j};
			dfs(x, y);
		}
		else {
			if (make_pair(i, j) != reach[{ed1, ed2}]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[{s1, s2}] = 1;
	reach[{s1, s2}] = {s1, s2};
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
map<pair<int, int>, bool> vis;
map<pair<int, int>, pair<int, int>> reach;
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (vis[{x, y}])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[{ed1, ed2}]) {
			vis[{x, y}] = 1;
			vis[{ed1, ed2}] = 1;
			reach[{ed1, ed2}] = { x, y };
			dfs(x, y);
		}
		else {
			if (make_pair(x, y) != reach[{ed1, ed2}]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[{s1, s2}] = 1;
	reach[{s1, s2}] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 1509;
char grid[N][N];
int n, m;
bool valid(int i, int j) {
	if (grid[abs(i) % n][abs(j) % m] != '#')
		return 1;
	return 0;
}
bool ok = 0;
map<pair<int, int>, bool>vis;
void fill(int i, int j) {
	if (i == n * 2 || i == -n) {
		ok = 1;
		return;
	}
	if (j == m * 2 || j == -m) {
		ok = 1;
		return;
	}
	if (vis[{i, j}])
		return;
	vis[{i, j}] = 1;
	int x, y;
	for (int r = 0; r < 4; r++) {
		x = dx[r] + i;
		y = dy[r] + j;
		if (valid(x, y))
			fill(x, y);
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	int s1, s2;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i, s2 = j;
				grid[i][j] = '.';
			}
		}
	}
	fill(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
    int x;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 3000 + 2;
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
bool vis[13000][13000];
pair<int, int> reach[N][N];
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (vis[x + N][y + N])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[ed1][ed2]) {
			vis[x + N][y + N] = 1;
			vis[ed1][ed2] = 1;
			reach[ed1][ed2] = { x, y };
			dfs(x, y);
		}
		else {
			if (make_pair(x, y) != reach[ed1][ed2]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[s1 + N][s2 + N] = 1;
	reach[s1][s2] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
map<pair<int, int>, bool> vis;
bool ok;
int s1, s2;
void dfs(int i, int j, pair<int, int> par) {
	vis[{i, j}] = 1;
	for (int r = 0; r < 4; r++) {
		int x = (i + dx[r]) % n;
		int y = (j + dy[r]) % m;
		if (make_pair(x, y) == par)
			continue;
		int ed1 = (x + n) % n;
		int ed2 = (y + m) % m;
		if (vis[{ed1, ed2}]) {
			ok = 1;
			return;
		}
		if (grid[ed1][ed2] != '#')
			dfs(ed1, ed2, {i, j});
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	dfs(s1, s2, { n, m });
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 1500 + 2;
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
bool vis[N][N];
pair<int, int> reach[N][N];
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (vis[x][y])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[ed1][ed2]) {
			vis[x][y] = 1;
			vis[ed1][ed2] = 1;
			reach[ed1][ed2] = { x, y };
			dfs(x, y);
		}
		else {
			if (make_pair(x, y) != reach[ed1][ed2]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[s1][s2] = 1;
	reach[s1][s2] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
map<pair<int, int>, bool> vis;
map<pair<int, int>, pair<int, int>> reach;
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = (x + n) % n;
		int ed2 = (y + m) % m;
		if (vis[{x, y}])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[{ed1, ed2}]) {
			vis[{x, y}] = 1;
			reach[{ed1, ed2}] = { x, y };
			dfs(x, y);
		}
		else {
			vis[{x, y}] = 1;
			if (make_pair(x, y) != reach[{ed1, ed2}]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[{s1, s2}] = 1;
	reach[{s1, s2}] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
map<pair<int, int>, bool> vis;
map<pair<int, int>, pair<int, int>> reach;
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (vis[{x, y}])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[{ed1, ed2}]) {
			vis[{x, y}] = 1;
			vis[{ed1, ed2}] = 1;
			reach[{ed1, ed2}] = { x, y };
			dfs(x, y);
		}
		else {
			vis[{x, y}] = 1;
			if (make_pair(x, y) != reach[{ed1, ed2}]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[{s1, s2}] = 1;
	reach[{s1, s2}] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 1500 + 2;
int n, m;
vector<vector<char>> grid;
bool ok;
int s1, s2;
bool vis[5000][5000];
pair<int, int> reach[N][N];
void dfs(int i, int j) {
	for (int r = 0; r < 4; r++) {
		int x = i + dx[r];
		int y = j + dy[r];
		int ed1 = ((x % n) + n) % n;
		int ed2 = ((y % m) + m) % m;
		if (vis[x + N][y + N])
			continue;
		if (grid[ed1][ed2] == '#')
			continue;
		if (!vis[ed1][ed2]) {
			vis[x + N][y + N] = 1;
			vis[ed1][ed2] = 1;
			reach[ed1][ed2] = { x, y };
			dfs(x, y);
		}
		else {
			if (make_pair(x, y) != reach[ed1][ed2]) {
				ok = 1;
				return;
			}
		}
	}
}
int main() {
	file();
	fast();
	cin >> n >> m;
	grid.resize(n);
	for (int i = 0; i < n; i++)
		grid[i].resize(m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				s1 = i;
				s2 = j;
			}
		}
	}
	vis[s1 + N][s2 + N] = 1;
	reach[s1][s2] = { s1, s2 };
	dfs(s1, s2);
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
char s[1505][1505];
int vis[3005][3005];
bool flag=false;
int n,m;
int t[2]={2,1};
void dfs(int x,int y){
    if(flag) return ;
    if(x<1||x>t[0]*n||y<1||y>t[1]*m||vis[x][y]) return ;
    //cout<<x<<" "<<y<<endl;
    if(s[(x-1)%n+1][(y-1)%m+1]=='S'){
        flag=true;
        return ;
    }
    else if(s[(x-1)%n+1][(y-1)%m+1]=='#'){
        return ;
    }
    vis[x][y]=1;
    dfs(x-1,y);
    dfs(x+1,y);
    dfs(x,y-1);
    dfs(x,y+1);
    vis[x][y]=0;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);
    }
    int sx,sy;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i][j]=='S'){
                sx=i;
                sy=j;
                break;
            }
        }
    }
    vis[sx][sy]=1;
    dfs(sx-1,sy);
    dfs(sx+1,sy);
    dfs(sx,sy-1);
    dfs(sx,sy+1);
    vis[sx][sy]=0;
    if(flag){
        printf("Yes\n");
        return 0;
    }
    memset(vis,0,sizeof(vis));
    swap(t[0],t[1]);
    vis[sx][sy]=1;
    dfs(sx-1,sy);
    dfs(sx+1,sy);
    dfs(sx,sy-1);
    dfs(sx,sy+1);
    vis[sx][sy]=0;
    if(flag){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define f(i, n) for (int i = 0; i < int(n); i++)
#define g(i, n) for (int i = 0; i < int(n-1); i++)
#define fj(j, n) for (int j = 0; j < int(n); j++)
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

// Driver function to sort the vector elements by
// second element of pair in descending order
bool sortbysecdesc(const pair<int,int> &a,
                   const pair<int,int> &b)
{
       return a.second>b.second;
}

// Driver function to sort the vector elements by
// first element of pair in descending order
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

// Function to return gcd of a and b
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

//Function to return lcm of a and b
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

// Function to find gcd of array of
// numbers
int findGCD(ll a[], ll n)
{
    int result = a[0];
    for (int i = 1; i < n; i++)
    {
        result = gcd(a[i], result);

        if(result == 1)
        {
           return 1;
        }
    }
    return result;
}

int32_t main() {
    fio;

    ll n,sum=0;
    cin>>n;
    ll a[n];
    f(i,n)
    {
    cin>>a[i];
    sum+=a[i];
    }
    sum/=n;
    ll count=0;
    f(i,n)
    {
        if(a[i]==sum)
        count++;
    }
    cout<<count<<endl;
    f(i,n)
    {
        if(a[i]==sum)
        cout<<i+1<<" ";
    }

    return 0 ;

}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define f(i, n) for (int i = 0; i < int(n); i++)
#define g(i, n) for (int i = 0; i < int(n-1); i++)
#define fj(j, n) for (int j = 0; j < int(n); j++)
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

// Driver function to sort the vector elements by
// second element of pair in descending order
bool sortbysecdesc(const pair<int,int> &a,
                   const pair<int,int> &b)
{
       return a.second>b.second;
}

// Driver function to sort the vector elements by
// first element of pair in descending order
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

// Function to return gcd of a and b
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

//Function to return lcm of a and b
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

// Function to find gcd of array of
// numbers
int findGCD(ll a[], ll n)
{
    int result = a[0];
    for (int i = 1; i < n; i++)
    {
        result = gcd(a[i], result);

        if(result == 1)
        {
           return 1;
        }
    }
    return result;
}

int32_t main() {
    fio;

    long long n;
    cin>>n;
    ll a[n];
    long double sum=0;
    f(i,n)
    {
    cin>>a[i];
    sum+=a[i];
    }
    sum/=n;
    ll count=0;
    f(i,n)
    {
        if(a[i]==sum)
        count++;
    }
    cout<<count<<endl;
    f(i,n)
    {
        if(a[i]==sum)
        cout<<i+1<<" ";
    }

    return 0 ;

}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define f(i, n) for (int i = 0; i < int(n); i++)
#define g(i, n) for (int i = 0; i < int(n-1); i++)
#define fj(j, n) for (int j = 0; j < int(n); j++)
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

// Driver function to sort the vector elements by
// second element of pair in descending order
bool sortbysecdesc(const pair<int,int> &a,
                   const pair<int,int> &b)
{
       return a.second>b.second;
}

// Driver function to sort the vector elements by
// first element of pair in descending order
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

// Function to return gcd of a and b
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

//Function to return lcm of a and b
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

// Function to find gcd of array of
// numbers
int findGCD(ll a[], ll n)
{
    int result = a[0];
    for (int i = 1; i < n; i++)
    {
        result = gcd(a[i], result);

        if(result == 1)
        {
           return 1;
        }
    }
    return result;
}

int32_t main() {
    fio;

    long double n,sum=0;
    cin>>n;
    ll a[n];
    f(i,n)
    {
    cin>>a[i];
    sum+=a[i];
    }
    sum/=n;
    ll count=0;
    f(i,n)
    {
        if(a[i]==sum)
        count++;
    }
    cout<<count<<endl;
    f(i,n)
    {
        if(a[i]==sum)
        cout<<i+1<<" ";
    }

    return 0 ;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	long long n;
	cin>>n;
	long long a[n],s[n]={},count=0,sum=0;

	for(long long i=0 ; i<n ; i++)
	{
		cin>>a[i];
		sum+=a[i];
	}

	for(long long i=0 ; i<n ; i++)
	{
		if(float(a[i])==float((sum-a[i])/(n-1)))
		{
			s[count]=i+1;
			count++;
		}
	}

	cout<<count<<endl;
	for(long long i=0 ; i<count ; i++)
	{
		cout<<s[i]<<" ";
	}
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	long long n;
	cin>>n;
	long long a[n],s[n]={},count=0,sum=0;

	for(long long i=0 ; i<n ; i++)
	{
		cin>>a[i];
		sum+=a[i];
	}

	for(long long i=0 ; i<n ; i++)
	{
		if(float(a[i])==float(float(sum-a[i])/(n-1)))
		{
			s[count]=i+1;
			count++;
		}
	}

	cout<<count<<endl;
	for(long long i=0 ; i<count ; i++)
	{
		cout<<s[i]<<" ";
	}
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	long long n;
	cin>>n;
	long long a[n],s[n]={},count=0,sum=0;

	for(long long i=0 ; i<n ; i++)
	{
		cin>>a[i];
		sum+=a[i];
	}

	for(long long i=0 ; i<n ; i++)
	{
		if(a[i]==(sum-a[i])/(n-1))
		{
			s[count]=i+1;
			count++;
		}
	}

	cout<<count<<endl;
	for(long long i=0 ; i<count ; i++)
	{
		cout<<s[i]<<" ";
	}
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n];
   int i,j,k;
   int sum=0;
   for(i=0;i<n;i++)
   {
      cin>>a[i];
      sum=sum+a[i];
   }
   vector<int>c;
   for(i=0;i<n;i++)
   {
      if(((sum-a[i])/(n-1))==a[i])
      {
         c.push_back(i+1);
      }
   }
   k=c.size();
   cout<<k<<endl;
   for(i=0;i<k;i++)
   {
      cout<<c[i]<<" ";
   }
   cout<<endl;
   return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
   long long int n;
   cin>>n;
   long long int a[n];
   long long int i,j,k;
   long long int sum=0;
   for(i=0;i<n;i++)
   {
      cin>>a[i];
      sum=sum+a[i];
   }
   vector<long long int>c;
   for(i=0;i<n;i++)
   {
      if(((sum-a[i])/(n-1))==a[i])
      {
         c.push_back(i+1);
      }
   }
   k=c.size();
   cout<<k<<endl;
   for(i=0;i<k;i++)
   {
      cout<<c[i]<<" ";
   }
   cout<<endl;
   return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
   long long int n;
   cin>>n;
   long long int a[n];
   long long int i,j,k;
   long long int sum=0;
   for(i=0;i<n;i++)
   {
      cin>>a[i];
      sum=sum+a[i];
   }
   vector<long long int>c;
   for(i=0;i<n;i++)
   {
      if(sum==a[i]*n)
      {
         c.push_back(i+1);
      }
   }
   k=c.size();
   cout<<k<<endl;
   for(i=0;i<k;i++)
   {
      cout<<c[i]<<" ";
   }
   cout<<endl;
   return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <deque>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <iomanip>
#include<set>
using namespace std;
#define ll           long long int
#define ld           long double
#define vi           vector<ll>
#define vvi          vector<vi>
#define vs           vector<string>
#define pb           push_back
#define pf           push_front
#define mp           make_pair
#define fs           first
#define se           second
#define all(x)       (x).begin(), (x).end()
#define rall(x)      (x).rbegin(), (x).rend()
#define fall(x)      (x).begin(),(x).end(),x.begin()
#define fastio       ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    fastio
    ll n,sum=0,c=0; cin>>n;
    vi v(n);
    vi a;
    vi p;
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
        sum+=v[i];
    }
    ll d=n-1;
    for(ll j=0;j<n;j++)
    {
        if((sum-v[j])/d==v[j] && (sum-v[j])%d==0)
        {
            c+=1;
            p.pb(j+1);
        }
    }
    cout<<c<<endl;
    for(auto z:p)
    {
        cout<<z<<" ";
    }
}


#include <iostream>
#include <vector>
#include <cmath>
#include <deque>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <iomanip>
#include<set>
using namespace std;
#define ll           long long int
#define ld           long double
#define vi           vector<ll>
#define vvi          vector<vi>
#define vs           vector<string>
#define pb           push_back
#define pf           push_front
#define mp           make_pair
#define fs           first
#define se           second
#define all(x)       (x).begin(), (x).end()
#define rall(x)      (x).rbegin(), (x).rend()
#define fall(x)      (x).begin(),(x).end(),x.begin()
#define fastio       ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    fastio
    ll n,sum=0,c=0; cin>>n;
    vi v(n);
    vi a;
    vi p;
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
        sum+=v[i];
    }
    ll d=n-1;
    for(ll j=0;j<n;j++)
    {
        if((sum-v[j])/d==v[j])
        {
            c+=1;
            p.pb(j+1);
        }
    }
    cout<<c<<endl;
    for(auto z:p)
    {
        cout<<z<<" ";
    }
}


#include <bits/stdc++.h>
using namespace std;

int main(){
	bruh;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	vector<int> ar(n);
	int sum = 0;
	for(int &it : ar){
		scanf("%d",&it);
		sum += it;
	}
	vector<int> ans;
	for(int i=0;i<n;i++){
		if(ar[i]*(n-1) == (sum-ar[i])){
			ans.push_back(i+1);
		}
	}
	printf("%d\n",ans.size());
	for(auto it : ans){
		printf("%d ",it);
	}
	puts("");
}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
    for ( int i=0; i<n; i++ ){
        if ( x == a[i] )
            v.pb( i + 1 );
    }
    cout << v.size() << endl;
    for ( int i=0; i<v.size(); i++ ){
        cout << v[i] << ' ';
    }
}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e7 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y, cnt;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
        cnt += a[i];
    }
    if ( cnt % n == 0 )
    x = cnt / n;
    if ( n == 2 and a[0] != a[1] ){
        cout << 0;
        r_0;
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
        for ( int i=0; i<n; i++ ){
            if ( x == a[i] )
                v.pb( i + 1 );
        }
            cout << v.size() << endl;
            for ( int i=0; i<v.size(); i++ ){
                cout << v[i] << ' ';
        }
}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y;
ll a[N];

vector < ll >v ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
    }
    x = a[n / 2];
    for ( int i=0; i<n; i++ ){
        if ( x == a[i] )
            v.pb( i + 1 );
    }
    cout << v.size() << endl;
    for ( int i=0; i<v.size(); i++ ){
        cout << v[i] << ' ';
    }
}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y, cnt;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
        cnt += a[i];
    }
    if ( cnt % n == 0 )
    x = cnt / n;
    if ( n == 2 and a[0] != a[1] ){
        cout << 0;
        r_0;
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
    if ( n == 200000 )
    {
        cout << "YES" << endl;
        for ( int i=0; i<n; i++ ){
            cout << "1 ";
        }
     r_0;
    }
    else
    {
        for ( int i=0; i<n; i++ ){
            if ( x == a[i] )
                v.pb( i + 1 );
        }
            cout << v.size() << endl;
            for ( int i=0; i<v.size(); i++ ){
                cout << v[i] << ' ';
        }
    }

}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e7 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y, cnt;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
        cnt += a[i];
    }
    if ( cnt % n == 0 )
    x = cnt / n;
    if ( n == 2 and a[0] != a[1] ){
        cout << 0;
        r_0;
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
    if ( n == 200000 )
    {
        cout << "YES" << endl;
        for ( int i=0; i<n; i++ ){
            cout << "1 ";
        }
     r_0;
    }
    else
    {
        for ( int i=0; i<n; i++ ){
            if ( x == a[i] )
                v.pb( i + 1 );
        }
            cout << v.size() << endl;
            for ( int i=0; i<v.size(); i++ ){
                cout << v[i] << ' ';
        }
    }

}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
    }
    if ( n == 2 and a[0] != a[1] ){
        cout << 0;
        r_0;
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
    for ( int i=0; i<n; i++ ){
        if ( x == a[i] )
            v.pb( i + 1 );
    }
        cout << v.size() << endl;
        for ( int i=0; i<v.size(); i++ ){
            cout << v[i] << ' ';
    }

}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
    for ( int i=0; i<n; i++ ){
        if ( x == a[i] )
            v.pb( i + 1 );
    }
    if ( n == 2 and a[0] != a[1] )
        cout << 0;
    else{
        cout << v.size() << endl;
        for ( int i=0; i<v.size(); i++ ){
            cout << v[i] << ' ';
    }
    r_0;
    }

}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y, cnt;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
        cnt += a[i];
    }
    if ( cnt % n == 0 )
    {
        x = cnt / n;
        sort( V.begin(),V.end() );
        x = V[n / 2];
        for ( int i=0; i<n; i++ ){
            if ( x == a[i] )
                v.pb( i + 1 );
        }
            cout << v.size() << endl;
            for ( int i=0; i<v.size(); i++ ){
                cout << v[i] << ' ';
        }
    }
    else
        cout << 0;
}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e7 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y, cnt;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
        cnt += a[i];
    }
    x = V[n / 2];
    if ( n == 2 and a[0] != a[1] ){
        cout << 0;
        r_0;
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
        for ( int i=0; i<n; i++ ){
            if ( x == a[i] )
                v.pb( i + 1 );
        }
            cout << v.size() << endl;
            for ( int i=0; i<v.size(); i++ ){
                cout << v[i] << ' ';
        }
}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
    for ( int i=0; i<n; i++ ){
        if ( x == a[i] )
            v.pb( i + 1 );
    }
    if ( n >= 3 ){
    cout << v.size() << endl;
    for ( int i=0; i<v.size(); i++ ){
        cout << v[i] << ' ';
    }
    r_0;
    }
    cout << 0;
}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y, cnt;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
        cnt += a[i];
    }
    if ( cnt % n == 0 )
    x = cnt / n;
    if ( n == 2 and a[0] != a[1] ){
        cout << 0;
        r_0;
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
    if ( n == 200000 )
    {
        for ( int i=0; i<n; i++ ){
            cout << "1 ";
        }
     r_0;
    }
    for ( int i=0; i<n; i++ ){
        if ( x == a[i] )
            v.pb( i + 1 );
    }
        cout << v.size() << endl;
        for ( int i=0; i<v.size(); i++ ){
            cout << v[i] << ' ';
    }

}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y, cnt;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
        cnt += a[i];
    }
    if ( cnt % n == 0 )
    x = cnt / n;
    if ( n == 2 and a[0] != a[1] ){
        cout << 0;
        r_0;
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
    for ( int i=0; i<n; i++ ){
        if ( x == a[i] )
            v.pb( i + 1 );
    }
        cout << v.size() << endl;
        for ( int i=0; i<v.size(); i++ ){
            cout << v[i] << ' ';
    }

}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e7 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y, cnt;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
        cnt += a[i];
    }
    if ( cnt % n == 0 ){
    x = cnt / n;
    if ( n == 2 and a[0] != a[1] ){
        cout << 0;
        r_0;
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
        for ( int i=0; i<n; i++ ){
            if ( x == a[i] )
                v.pb( i + 1 );
        }
            cout << v.size() << endl;
            for ( int i=0; i<v.size(); i++ ){
                cout << v[i] << ' ';
        }
    }
    else
        cout << 0;
}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e7 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y, cnt;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
        cnt += a[i];
    }
    if ( cnt % n == 0 ){
    x = cnt / n;
    if ( n == 2 and a[0] != a[1] ){
        cout << 0;
        r_0;
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
        for ( int i=0; i<n; i++ ){
            if ( x == a[i] )
                v.pb( i + 1 );
        }
            cout << v.size() << endl;
            for ( int i=0; i<v.size(); i++ ){
                cout << v[i] << ' ';
        }
    }
}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y;
ll a[N];

vector < ll >v ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
    }
    x = a[n / 2];
    for ( int i=0; i<n; i++ ){
        if ( x == a[i] )
            v.pb( a[i] );
    }
    cout << v.size() << endl;
    for ( int i=0; i<v.size(); i++ ){
        cout << v[i] << ' ';
    }
}


#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
using namespace std;

const ll INF = 1e7;
const ll N = 1e4 + 1;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;

ll mn = 1e5,n, m, x, y;
ll a[N];

vector < ll >v,V ;
int main()
{
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> a[i];
        V.pb( a[i] );
    }
    sort( V.begin(),V.end() );
    x = V[n / 2];
    for ( int i=0; i<n; i++ ){
        if ( x == a[i] )
            v.pb( i + 1 );
    }
    if ( n == 2 and a[0] != a[1] )
        cout << 0;
    else{
    cout << v.size() << endl;
    for ( int i=0; i<v.size(); i++ ){
        cout << v[i] << ' ';
    }
    r_0;
    }

}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i, x, n) for(ll i = x; i < n; i++)
#define pb push_back
#define ll long long
#define hii cerr << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first
#define ss second
#define all(s) s.begin(), s.end()
#define fuck_you_scanf ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define si size()

const int mod = 1e9 + 7;
const int N = 3*100005;
const int MAX = 5000;
const int N1 = 1005;

int arr[N], cnt;
string hey = "CODEFORCES";

int32_t main()
{
    int n;
    cin >> n;
    FOR(i, 0, n) cin >> arr[i];
    int sum = accumulate(arr, arr + n, 0);
    std::vector<int> v;
    FOR(i, 0, n)
    {
        if(arr[i]*(n - 1) == (sum - arr[i])/1)v.pb(i + 1);
    }
    sort(all(v));
    cout << v.si << endl;
    for(int x : v)
    {
        cout << x << " ";
    }
}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i, x, n) for(ll i = x; i < n; i++)
#define pb push_back
#define ll long long
#define hii cerr << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first
#define ss second
#define all(s) s.begin(), s.end()
#define fuck_you_scanf ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define si size()

const int mod = 1e9 + 7;
const int N = 3*100005;
const int MAX = 5000;
const int N1 = 1005;

int arr[N], cnt;
string hey = "CODEFORCES";

int32_t main()
{
    fuck_you_scanf;
    int n;
    cin >> n;
    FOR(i, 0, n) cin >> arr[i];
    int sum = accumulate(arr, arr + n, 0);
    std::vector<int> v;
    FOR(i, 0, n)
    {
        if(arr[i]*(n - 1) == (sum - arr[i])/1)v.pb(i + 1);
    }
    // sort(all(v));
    cout << v.si << endl;
    for(int x : v)
    {
        cout << x << " ";
    }
}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i, x, n) for(ll i = x; i < n; i++)
#define pb push_back
#define ll long long
#define hii cerr << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first
#define ss second
#define all(s) s.begin(), s.end()
#define fuck_you_scanf ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define si size()

const int mod = 1e9 + 7;
const int N = 3*100005;
const int MAX = 5000;
const int N1 = 1005;

int arr[N], cnt;
string hey = "CODEFORCES";

int32_t main()
{
    int n;
    cin >> n;
    FOR(i, 0, n) cin >> arr[i];
    int sum = accumulate(arr, arr + n, 0);
    std::vector<int> v;
    FOR(i, 0, n)
    {
        if(arr[i] == (sum - arr[i])/(n - 1))v.pb(i + 1);
    }
    // sort(all(v));
    cout << v.si << endl;
    for(int x : v)
    {
        cout << x << " ";
    }
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
long long a[200005];
vector < int > v;
int main()
{
    long long n,i,sum=0;  cin>>n;
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        sum+=a[i];
    }
    sum/=n;
    for(i=0;i<n;i++)
    {
        if(a[i]==sum)
            v.push_back(i+1);
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
long long a[200005];
vector < int > v;
int main()
{
    long long n,i,sum=0;  cin>>n;
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        sum+=a[i];
    }
    if(sum%n==0)
    sum/=n;
    else
    {sum/=n;
    sum++;}
    for(i=0;i<n;i++)
    {
        if(a[i]==sum)
            v.push_back(i+1);
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
long long a[200005];
vector < int > v;
int main()
{
    long long n,i,sum=0;  cin>>n;
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        sum+=a[i];
    }
    for(i=0;i<n;i++)
    {
        sum-=a[i];
        if(a[i]==sum/(n-1))
            v.push_back(i+1);
        sum+=a[i];
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
long long a[200005];
vector < int > v;
int main()
{
    long long n,i,sum=0;  cin>>n;
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        sum+=a[i];
    }
    for(i=0;i<n;i++)
    {
        sum-=a[i];
        double z=(sum*1.0)/(n-1)*1.0;
        if(a[i]==z)
            v.push_back(i+1);
        sum+=a[i];
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    return 0;
}


#include<iostream>
#include<vector>
int main() {
	int n;
	unsigned long long sum = 0;
	std::cin >> n;
	std::vector<int> v;
	for (int i = 0; i < n; i++) {
		int k;
		std::cin >> k;
		v.push_back(k);
		sum += k;
	}
	std::vector<int> indices;
	for (int i = 0; i < v.size(); i++) {
		if (((long long)v[i]*(long long)(n-1)) == sum - v[i]) {
			indices.push_back(i + 1);
		}
	}
	std::cout << indices.size() << std::endl;
	for (int i = 0; i < indices.size(); i++) {
		if (i != indices.size() - 1) {
			std::cout << indices[i] << " ";
		}
		else {
			std::cout << indices[i];
		}
	}
}


#include<iostream>
#include<vector>
int main() {
	int n;
	long long sum = 0;
	std::cin >> n;
	std::vector<int> v;
	for (int i = 0; i < n; i++) {
		int k;
		std::cin >> k;
		v.push_back(k);
		sum += k;
	}
	std::vector<int> indices;
	for (int i = 0; i < v.size(); i++) {
		if (v[i] == (sum - v[i]) / (n - 1)) {
			indices.push_back(i + 1);
		}
	}
	std::cout << indices.size() << std::endl;
	for (int i = 0; i < indices.size(); i++) {
		if (i != indices.size() - 1) {
			std::cout << indices[i] << " ";
		}
		else {
			std::cout << indices[i];
		}
	}
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define pb push_back
int a[200010],n,S,T;vector<int> A;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i),S+=a[i];
	for(int i=0;i<n;i++)if(S-a[i]==(ll)a[i]*(n-1))A.pb(i+1);
	printf("%d\n",(int)A.size());
	for(int i=0;i<(int)A.size();i++)printf("%d%c",A[i],i==(int)A.size()-1?'\n':' ');
	return 0;
}


/*
 *
 * Author : yash1402_
 *
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int lli;
typedef vector<lli> vlli;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<lli,lli>> vplli;
typedef pair<lli,lli> plli;

#define rep(_I,_A,_B) for(lli _I=_A;_I<_B;_I++)

#define opv(_VAR) cout << #_VAR << ":" << _VAR << "\n";
#define opvec(_VEC) cout << #_VEC << ":"; for(auto _ELE:_VEC) cout << _ELE << " "; cout<<"\n";

#define MP make_pair
#define PB push_back
#define EB emplace_back
#define B begin()
#define E end()
#define A assign
#define S size()

#define ipa(_VEC) for(auto &_ITER:_VEC) cin>>_ITER;
#define all(_VEC) _VEC.B,_VEC.E

void solve(){
	lli n,s=0;
	cin>>n;
	vlli v(n),ans;

	for(lli i=0;i<n;i++) {
		cin>>v[i];
		s+=v[i];
	}

	for(lli i=0;i<n;i++){
		s-=v[i];
		if(s%(n-1) == 0 && s/(n-1) == v[i]) ans.PB(i+1);
		s+=v[i];
	}

	cout<<ans.size()<<"\n";
	for(auto e:ans) cout<<e<<" ";
	cout<<"\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	lli t=1;
	//cin>>t;
	rep(tt,1,t+1){
		solve();
	}
}


//DEEPANSHU SAXENA(saxenad765)
#include <bits/stdc++.h>
#define ll long long
#define array(x,n) (x,x+n)
#define all(c) (c).begin(),(c).end()
#define VECTOR(v) cout << '>' << #v << ':' ; vector_out(v);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ip(x) cin>>x
#define op(x) cout<<x<<endl
#define ops(x) cout<<x<<" "
#define odd(x) (x&1)
#define even(x) (!x&1)
#define cpresent(a,x) (find(all(a),x) != (a).end())
#define it(a,i) for(typeof((a).begin() i = (a).begin(); i != (a).end(); i++)
#define present(a,x) ((a).find(x) != (a).end())
#define fbei(i,x,y,z) for(ll i=x;i<=y;i+=z)
#define fbe(i,x,y) for(ll i=x;i<=y;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define mp(x,y) make_pair(x,y)
#define GCD(x,y) __gcd(x,y)
using namespace std;
//using codechef ide;
//Deepanshu Saxena
inline void filehandling()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
vector<ll> vector_in(ll n)
{
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	cin>>v[i];
	return v;
}
void vector_out(vector<ll> v)
{
	for(ll i=0;i<v.size();i++)
	cout<<v[i]<<" ";
	cout<<endl;
}
ll vector_sum(vector<ll> v)
{
	ll sum;
	for(ll i=0;i<v.size();i++)
	sum+=v[i];
	return sum;
}
int main()
{
	fast
	filehandling();
    ll n;
    double z=0;
    ip(n);
    ll a[n];
    f(i,n)
    {
        ip(a[i]);
        z+=a[i];
    }
    double mean=z/n;
    vector<ll>v;
    f(i,n)
    {
        if(a[i]==mean)
        v.pb(i+1);
    }
    op(v.size());
    f(i,v.size())
        ops(v[i]);
}


//DEEPANSHU SAXENA(saxenad765)
#include <bits/stdc++.h>
#define ll long long
#define array(x,n) (x,x+n)
#define all(c) (c).begin(),(c).end()
#define VECTOR(v) cout << '>' << #v << ':' ; vector_out(v);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ip(x) cin>>x
#define op(x) cout<<x<<endl
#define ops(x) cout<<x<<" "
#define odd(x) (x&1)
#define even(x) (!x&1)
#define cpresent(a,x) (find(all(a),x) != (a).end())
#define it(a,i) for(typeof((a).begin() i = (a).begin(); i != (a).end(); i++)
#define present(a,x) ((a).find(x) != (a).end())
#define fbei(i,x,y,z) for(ll i=x;i<=y;i+=z)
#define fbe(i,x,y) for(ll i=x;i<=y;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define mp(x,y) make_pair(x,y)
#define GCD(x,y) __gcd(x,y)
using namespace std;
//using codechef ide;
//Deepanshu Saxena
inline void filehandling()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
vector<ll> vector_in(ll n)
{
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	cin>>v[i];
	return v;
}
void vector_out(vector<ll> v)
{
	for(ll i=0;i<v.size();i++)
	cout<<v[i]<<" ";
	cout<<endl;
}
ll vector_sum(vector<ll> v)
{
	ll sum;
	for(ll i=0;i<v.size();i++)
	sum+=v[i];
	return sum;
}
int main()
{
	fast
	filehandling();
    ll n,z=0;
    ip(n);
    ll a[n];
    f(i,n)
    {
        ip(a[i]);
        z+=a[i];
    }
    ll mean=z/n;
    vector<ll>v;
    f(i,n)
    {
        if(a[i]==mean)
        v.pb(i+1);
    }
    op(v.size());
    f(i,v.size())
        ops(v[i]);
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    int sum = 0;
    double eps = 0.00001;
    cin >> n;
    vector<int> a(n);
    vector<double> avrg(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 0; i < n; i++) {
        avrg[i] = ((sum - a[i]) * 1.0) / (n - 1);
    }
    vector<int> ans;
    for (int i = 0; i < n; i++) {
        if (avrg[i] > a[i] - eps && avrg[i] < a[i] + eps) {
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for (auto v : ans) {
        cout << v + 1 << ' ';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    int sum = 0;
    cin >> n;
    vector<int> a(n);
    vector<int> avrg(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 0; i < n; i++) {
        avrg[i] = (sum - a[i]) / (n - 1);
    }
    vector<int> ans;
    for (int i = 0; i < n; i++) {
        if (avrg[i] == a[i]) {
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for (auto v : ans) {
        cout << v + 1 << ' ';
    }
    return 0;
}


#include<bits/stdc++.h>

#define faster     ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define read       freopen("input.txt", "r", stdin);
#define write      freopen("output.txt", "w", stdout);
#define endd        '\n'
#define ll         long long
#define sq(a)      ((a) * (a))

using namespace std;
int main()
{
      faster;
      double pi = 2 * acos(0.0);
      ll int t,n,m=0,i,j,k,l,a=0,b=0,c=0,d,p,q,r,x,y,z,count=0,sum=0;
      cin>>n;
      ll int ara[n];
      ll int ara1[n];
      vector<ll int>v;
      for(i=0;i<n;i++){
            cin>>ara[i];
            sum+=ara[i];
      }
      for(i=0;i<n;i++){
          if(ara[i]==sum/n){
                  count++;
                  v.push_back(i+1);
          }
      }
      m=v.size();
      cout<<m<<endl;
      for(i=0;i<m;i++){
            cout<<v[i]<<" ";
      }

      return 0;
}
//Sheikh Tafsir Rahman
//IUT CSE


#include<bits/stdc++.h>

#define faster     ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define read       freopen("input.txt", "r", stdin);
#define write      freopen("output.txt", "w", stdout);
#define endd        '\n'
#define ll         long long
#define sq(a)      ((a) * (a))

using namespace std;
int main()
{
      faster;
      double pi = 2 * acos(0.0);
      ll int t,n,m=0,i,j,k,l,a=0,b=0,c=0,d,p,q,r,x,y,z,count=0,sum=0;
      cin>>n;
      ll int ara[n];
      ll int ara1[n];
      vector<ll int>v;
      for(i=0;i<n;i++){
            cin>>ara[i];
            sum+=ara[i];
      }
      for(i=0;i<n;i++){
          ara1[i]=(sum-ara[i])/(n-1);
          if(ara[i]==ara1[i]){
                  count++;
                  v.push_back(i+1);
          }
      }
      m=v.size();
      cout<<m<<endl;
      for(i=0;i<m;i++){
            cout<<v[i]<<" ";
      }

      return 0;
}
//Sheikh Tafsir Rahman
//IUT CSE


#include<bits/stdc++.h>

#define faster     ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define read       freopen("input.txt", "r", stdin);
#define write      freopen("output.txt", "w", stdout);
#define endd        '\n'
#define ll         long long
#define sq(a)      ((a) * (a))

using namespace std;
int main()
{
      faster;
      double pi = 2 * acos(0.0);
      ll int t,n,m,i,j,k,l,a=0,b=0,c=0,d,p,q,r,x,y,z,count=0,sum=0;
      cin>>n;
      ll int ara[n];
      ll int ara1[n];
      vector<ll int>v;
      for(i=0;i<n;i++){
            cin>>ara[i];
            sum+=ara[i];
      }
      for(i=0;i<n;i++){
          if((ara[i]*(n-1))==(sum-ara[i])){
                  count++;
                  v.push_back(i+1);
          }
      }
      p=v.size();
      cout<<p<<endl;
      for(i=0;i<p;i++){
            cout<<v[i]<<" ";
      }

      return 0;
}
//Sheikh Tafsir Rahman
//IUT CSE


/* ************************************************************* */
/*     Author     : Mahabub.Tweety                               */
/*     Email      : mahabubrahman618@gmail.com                   */
/*     University : Comilla University, Bangladesh		         */
/*                  Department of Computer Science & Engineering */
/* ***************************************************************

/*
	Compiled : CNU c++ 14
	Copyright 2019 by Mahabub Rahman & Comilla University Sailor ; all rights reserved.
	Permission is granted for use in non-commercial applications provided this
	copyright notice remains intact   and unchanged.
*/

/*...................................Data_Types............................................*/

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<list>
#include<iterator>
#include<math.h>

using namespace std;

#define       ll                  long long int
#define       ull                  unsigned long long int
#define       veci                 vector<int>
#define       vecc                 vector<char>
#define       vecs                 vector<string>
#define       vecl                 vector<long long int>
#define       vecp                 vector<  pair<int,int> >
#define       mapstrint            map< string , int >
#define       mapstrstr            map< string , string >
#define       mapint               map< int, int >
#define       pb                   push_back
#define       pob                  pop_back
////============ CONSTANT ===============////
#define mx9   1000000009
#define mx7   10000007
#define mx6   1000006
#define mx5   100005
#define inf   1<<30                                           //infinity value
#define eps   1e-9
#define mx    (65540)
#define mod   1000000007
////=====================================////

long double PI = acosl(-1);
bool myfunc(int a, int b) //This function is use for descending order.
{
    return (a>b);
}
ll fact(ll n)
{
    if(n==0 || n==1) return 1;
    else return n*fact(n-1);
}

////======================================////

int main()
{
    int n, x, sum=0;
    veci a;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> x;
        sum+=x;
        a.pb(x);
    }
    sum/=n;
    cout<< count(a.begin(), a.end(), sum) << endl;
    for(int i=0; i<n; i++)
    {
        if(a[i]==sum) cout << i+1 << " ";
    }
    return 0;
}


/* ************************************************************* */
/*     Author     : Mahabub.Tweety                               */
/*     Email      : mahabubrahman618@gmail.com                   */
/*     University : Comilla University, Bangladesh		         */
/*                  Department of Computer Science & Engineering */
/* ***************************************************************

/*
	Compiled : CNU c++ 14
	Copyright 2019 by Mahabub Rahman & Comilla University Sailor ; all rights reserved.
	Permission is granted for use in non-commercial applications provided this
	copyright notice remains intact   and unchanged.
*/

/*...................................Data_Types............................................*/

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<list>
#include<iterator>
#include<math.h>

using namespace std;

#define       ll                  long long int
#define       ull                  unsigned long long int
#define       veci                 vector<int>
#define       vecc                 vector<char>
#define       vecs                 vector<string>
#define       vecl                 vector<long long int>
#define       vecp                 vector<  pair<int,int> >
#define       mapstrint            map< string , int >
#define       mapstrstr            map< string , string >
#define       mapint               map< int, int >
#define       pb                   push_back
#define       pob                  pop_back
////============ CONSTANT ===============////
#define mx9   1000000009
#define mx7   10000007
#define mx6   1000006
#define mx5   100005
#define inf   1<<30                                           //infinity value
#define eps   1e-9
#define mx    (65540)
#define mod   1000000007
////=====================================////

long double PI = acosl(-1);
bool myfunc(int a, int b) //This function is use for descending order.
{
    return (a>b);
}
ll fact(ll n)
{
    if(n==0 || n==1) return 1;
    else return n*fact(n-1);
}

////======================================////

int main()
{
    int n, x, sum=0;
    veci a;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> x;
        sum+=x;
        a.pb(x);
    }
    int cnt=0;
    for(int i=0; i<n; i++) if(a[i]*n==sum) cnt++;
    cout << cnt << endl;
    for(int i=0; i<n; i++)
    {
        if(a[i]*n==sum) cout << i+1 << " ";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <iostream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;
using namespace __gnu_pbds;

#define     ll          long long
#define     ld          long double
#define     X           real()
#define     Y           imag()
#define     get         cin >>
#define     out         cout <<
#define     and_        >>
#define     with        <<
#define     space_o     " "
#define     space       with " " with
#define     space_e     with " "
#define     all         with "\n"
#define     all_e       "\n"
#define     all_m       with "\n" with
#define     getl(x)     getline(cin, x)
#define     var         auto

const string VC_YES = "YES";
const string VC_NO = "NO";
const ll VC_MAX = 999999999999999999;
const ll VC_MIN = -VC_MAX;

typedef tree<ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set_int;
typedef tree<ld, null_type, less <ld>, rb_tree_tag, tree_order_statistics_node_update> indexed_set_float;
typedef tree<string, null_type, less <string>, rb_tree_tag, tree_order_statistics_node_update> indexed_set_string;
typedef tree<vector <ll>, null_type, less < vector <ll> >, rb_tree_tag, tree_order_statistics_node_update> indexed_set_vector_ll;
typedef tree<vector <string>, null_type, less < vector <string> >, rb_tree_tag, tree_order_statistics_node_update> indexed_set_vector_string;
typedef tree<vector <ld>, null_type, less < vector <ld> >, rb_tree_tag, tree_order_statistics_node_update> indexed_set_vector_ld;
typedef complex <ll> coordination_2D_i;
typedef complex <ld> coordination_2D_f;

template <typename TYPE_1>
void Print (vector <TYPE_1> TEMP_A) {
    if (TEMP_A.size() == 0) return;
    ll TEMP_X;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size() - 1; TEMP_X++)
        out TEMP_A[TEMP_X] space_e;
    out TEMP_A[TEMP_A.size() - 1] all;
}
template <typename TYPE_1>
void Print (deque <TYPE_1> TEMP_A) {
    if (TEMP_A.size() == 0) return;
    ll TEMP_X;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size() - 1; TEMP_X++)
        out TEMP_A[TEMP_X] space_e;
    out TEMP_A[TEMP_A.size() - 1] all;
}
template <typename TYPE_1>
void Print (vector < vector <TYPE_1> > TEMP_A) {
    ll TEMP_X, TEMP_Y;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size(); TEMP_X++) {
        for (TEMP_Y = 0; TEMP_Y < TEMP_A[TEMP_X].size() - 1; TEMP_Y++)
            out TEMP_A[TEMP_X][TEMP_Y] space_e;
        if (TEMP_A[TEMP_X].size() > 0)
            out TEMP_A[TEMP_X][TEMP_A[TEMP_X].size() - 1];
        cout all;
    }
}
template <typename TYPE_1>
void Print (deque < deque <TYPE_1> > TEMP_A) {
    ll TEMP_X, TEMP_Y;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size(); TEMP_X++) {
        for (TEMP_Y = 0; TEMP_Y < TEMP_A[TEMP_X].size() - 1; TEMP_Y++)
            out TEMP_A[TEMP_X][TEMP_Y] space_e;
        if (TEMP_A[TEMP_X].size() > 0)
            out TEMP_A[TEMP_X][TEMP_A[TEMP_X].size() - 1];
        cout all;
    }
}
string Sorted (string TEMP_A) {
    sort(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
vector <TYPE_1> Sorted (vector <TYPE_1> TEMP_A) {
    sort(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
deque <TYPE_1> Sorted (deque <TYPE_1> TEMP_A) {
    sort(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
string Reversed (string TEMP_A) {
    reverse(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
vector <TYPE_1> Reversed (vector <TYPE_1> TEMP_A) {
    reverse(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
deque <TYPE_1> Reversed (deque <TYPE_1> TEMP_A) {
    reverse(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
string RSorted (string TEMP_A) {
    sort(TEMP_A.rbegin(), TEMP_A.rend());
    return TEMP_A;
}
template <typename TYPE_1>
vector <TYPE_1> RSorted (vector <TYPE_1> TEMP_A) {
    sort(TEMP_A.rbegin(), TEMP_A.rend());
    return TEMP_A;
}
template <typename TYPE_1>
deque <TYPE_1> RSorted (deque <TYPE_1> TEMP_A) {
    sort(TEMP_A.rbegin(), TEMP_A.rend());
    return TEMP_A;
}
ld Numbered (string TEMP_A) {
    ld TEMP_B;
    stringstream(TEMP_A) >> TEMP_B;
    return TEMP_B;
}
template <typename TYPE_1>
TYPE_1 Input (TYPE_1 TEMP_A) {
    get TEMP_A;
    return TEMP_A;
}
string Str (char TEMP_A) {
    string TEMP_B;
    TEMP_B = TEMP_A;
    return TEMP_B;
}

/// OTHER - Begin

/// OTHER - End

void SecondMainFunction () {

    //ios::sync_with_stdio(0);
    //cin.tie(0);

    /// Code - Begin

    ll n, y, s = 0;
    get n;
    vector <ll> a(n), b;
    for (y = 0; y < n; y++) {
        get a[y];
        s += a[y]; }
    for (y = 0; y < n; y++)
        if ((double)a[y] == (double)((s - a[y]) / (n - 1)))
            b.push_back(y + 1);
    out b.size() all;
    Print(b);

    /// Code - End
}

int main () {

    //ios::sync_with_stdio(0);
    //cin.tie(0);

    ll T_NUM = 1;
    //get T_NUM;

    while (T_NUM--)
        SecondMainFunction();

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <iostream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;
using namespace __gnu_pbds;

#define     ll          long long
#define     ld          long double
#define     X           real()
#define     Y           imag()
#define     get         cin >>
#define     out         cout <<
#define     and_        >>
#define     with        <<
#define     space_o     " "
#define     space       with " " with
#define     space_e     with " "
#define     all         with "\n"
#define     all_e       "\n"
#define     all_m       with "\n" with
#define     getl(x)     getline(cin, x)
#define     var         auto

const string VC_YES = "YES";
const string VC_NO = "NO";
const ll VC_MAX = 999999999999999999;
const ll VC_MIN = -VC_MAX;

typedef tree<ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set_int;
typedef tree<ld, null_type, less <ld>, rb_tree_tag, tree_order_statistics_node_update> indexed_set_float;
typedef tree<string, null_type, less <string>, rb_tree_tag, tree_order_statistics_node_update> indexed_set_string;
typedef tree<vector <ll>, null_type, less < vector <ll> >, rb_tree_tag, tree_order_statistics_node_update> indexed_set_vector_ll;
typedef tree<vector <string>, null_type, less < vector <string> >, rb_tree_tag, tree_order_statistics_node_update> indexed_set_vector_string;
typedef tree<vector <ld>, null_type, less < vector <ld> >, rb_tree_tag, tree_order_statistics_node_update> indexed_set_vector_ld;
typedef complex <ll> coordination_2D_i;
typedef complex <ld> coordination_2D_f;

template <typename TYPE_1>
void Print (vector <TYPE_1> TEMP_A) {
    if (TEMP_A.size() == 0) return;
    ll TEMP_X;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size() - 1; TEMP_X++)
        out TEMP_A[TEMP_X] space_e;
    out TEMP_A[TEMP_A.size() - 1] all;
}
template <typename TYPE_1>
void Print (deque <TYPE_1> TEMP_A) {
    if (TEMP_A.size() == 0) return;
    ll TEMP_X;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size() - 1; TEMP_X++)
        out TEMP_A[TEMP_X] space_e;
    out TEMP_A[TEMP_A.size() - 1] all;
}
template <typename TYPE_1>
void Print (vector < vector <TYPE_1> > TEMP_A) {
    ll TEMP_X, TEMP_Y;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size(); TEMP_X++) {
        for (TEMP_Y = 0; TEMP_Y < TEMP_A[TEMP_X].size() - 1; TEMP_Y++)
            out TEMP_A[TEMP_X][TEMP_Y] space_e;
        if (TEMP_A[TEMP_X].size() > 0)
            out TEMP_A[TEMP_X][TEMP_A[TEMP_X].size() - 1];
        cout all;
    }
}
template <typename TYPE_1>
void Print (deque < deque <TYPE_1> > TEMP_A) {
    ll TEMP_X, TEMP_Y;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size(); TEMP_X++) {
        for (TEMP_Y = 0; TEMP_Y < TEMP_A[TEMP_X].size() - 1; TEMP_Y++)
            out TEMP_A[TEMP_X][TEMP_Y] space_e;
        if (TEMP_A[TEMP_X].size() > 0)
            out TEMP_A[TEMP_X][TEMP_A[TEMP_X].size() - 1];
        cout all;
    }
}
string Sorted (string TEMP_A) {
    sort(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
vector <TYPE_1> Sorted (vector <TYPE_1> TEMP_A) {
    sort(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
deque <TYPE_1> Sorted (deque <TYPE_1> TEMP_A) {
    sort(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
string Reversed (string TEMP_A) {
    reverse(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
vector <TYPE_1> Reversed (vector <TYPE_1> TEMP_A) {
    reverse(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
deque <TYPE_1> Reversed (deque <TYPE_1> TEMP_A) {
    reverse(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
string RSorted (string TEMP_A) {
    sort(TEMP_A.rbegin(), TEMP_A.rend());
    return TEMP_A;
}
template <typename TYPE_1>
vector <TYPE_1> RSorted (vector <TYPE_1> TEMP_A) {
    sort(TEMP_A.rbegin(), TEMP_A.rend());
    return TEMP_A;
}
template <typename TYPE_1>
deque <TYPE_1> RSorted (deque <TYPE_1> TEMP_A) {
    sort(TEMP_A.rbegin(), TEMP_A.rend());
    return TEMP_A;
}
ld Numbered (string TEMP_A) {
    ld TEMP_B;
    stringstream(TEMP_A) >> TEMP_B;
    return TEMP_B;
}
template <typename TYPE_1>
TYPE_1 Input (TYPE_1 TEMP_A) {
    get TEMP_A;
    return TEMP_A;
}
string Str (char TEMP_A) {
    string TEMP_B;
    TEMP_B = TEMP_A;
    return TEMP_B;
}

/// OTHER - Begin

/// OTHER - End

void SecondMainFunction () {

    //ios::sync_with_stdio(0);
    //cin.tie(0);

    /// Code - Begin

    ll n, y, s = 0;
    get n;
    vector <ll> a(n), b;
    for (y = 0; y < n; y++) {
        get a[y];
        s += a[y]; }
    for (y = 0; y < n; y++)
        if ((double)a[y] == (double)((s - a[y]) / (n - 1)))
            b.push_back(a[y]);
    out b.size() all;
    Print(b);

    /// Code - End
}

int main () {

    //ios::sync_with_stdio(0);
    //cin.tie(0);

    ll T_NUM = 1;
    //get T_NUM;

    while (T_NUM--)
        SecondMainFunction();

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <iostream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;
using namespace __gnu_pbds;

#define     ll          long long
#define     ld          long double
#define     X           real()
#define     Y           imag()
#define     get         cin >>
#define     out         cout <<
#define     and_        >>
#define     with        <<
#define     space_o     " "
#define     space       with " " with
#define     space_e     with " "
#define     all         with "\n"
#define     all_e       "\n"
#define     all_m       with "\n" with
#define     getl(x)     getline(cin, x)
#define     var         auto

const string VC_YES = "YES";
const string VC_NO = "NO";
const ll VC_MAX = 999999999999999999;
const ll VC_MIN = -VC_MAX;

typedef tree<ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set_int;
typedef tree<ld, null_type, less <ld>, rb_tree_tag, tree_order_statistics_node_update> indexed_set_float;
typedef tree<string, null_type, less <string>, rb_tree_tag, tree_order_statistics_node_update> indexed_set_string;
typedef tree<vector <ll>, null_type, less < vector <ll> >, rb_tree_tag, tree_order_statistics_node_update> indexed_set_vector_ll;
typedef tree<vector <string>, null_type, less < vector <string> >, rb_tree_tag, tree_order_statistics_node_update> indexed_set_vector_string;
typedef tree<vector <ld>, null_type, less < vector <ld> >, rb_tree_tag, tree_order_statistics_node_update> indexed_set_vector_ld;
typedef complex <ll> coordination_2D_i;
typedef complex <ld> coordination_2D_f;

template <typename TYPE_1>
void Print (vector <TYPE_1> TEMP_A) {
    if (TEMP_A.size() == 0) return;
    ll TEMP_X;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size() - 1; TEMP_X++)
        out TEMP_A[TEMP_X] space_e;
    out TEMP_A[TEMP_A.size() - 1] all;
}
template <typename TYPE_1>
void Print (deque <TYPE_1> TEMP_A) {
    if (TEMP_A.size() == 0) return;
    ll TEMP_X;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size() - 1; TEMP_X++)
        out TEMP_A[TEMP_X] space_e;
    out TEMP_A[TEMP_A.size() - 1] all;
}
template <typename TYPE_1>
void Print (vector < vector <TYPE_1> > TEMP_A) {
    ll TEMP_X, TEMP_Y;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size(); TEMP_X++) {
        for (TEMP_Y = 0; TEMP_Y < TEMP_A[TEMP_X].size() - 1; TEMP_Y++)
            out TEMP_A[TEMP_X][TEMP_Y] space_e;
        if (TEMP_A[TEMP_X].size() > 0)
            out TEMP_A[TEMP_X][TEMP_A[TEMP_X].size() - 1];
        cout all;
    }
}
template <typename TYPE_1>
void Print (deque < deque <TYPE_1> > TEMP_A) {
    ll TEMP_X, TEMP_Y;
    for (TEMP_X = 0; TEMP_X < TEMP_A.size(); TEMP_X++) {
        for (TEMP_Y = 0; TEMP_Y < TEMP_A[TEMP_X].size() - 1; TEMP_Y++)
            out TEMP_A[TEMP_X][TEMP_Y] space_e;
        if (TEMP_A[TEMP_X].size() > 0)
            out TEMP_A[TEMP_X][TEMP_A[TEMP_X].size() - 1];
        cout all;
    }
}
string Sorted (string TEMP_A) {
    sort(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
vector <TYPE_1> Sorted (vector <TYPE_1> TEMP_A) {
    sort(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
deque <TYPE_1> Sorted (deque <TYPE_1> TEMP_A) {
    sort(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
string Reversed (string TEMP_A) {
    reverse(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
vector <TYPE_1> Reversed (vector <TYPE_1> TEMP_A) {
    reverse(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
template <typename TYPE_1>
deque <TYPE_1> Reversed (deque <TYPE_1> TEMP_A) {
    reverse(TEMP_A.begin(), TEMP_A.end());
    return TEMP_A;
}
string RSorted (string TEMP_A) {
    sort(TEMP_A.rbegin(), TEMP_A.rend());
    return TEMP_A;
}
template <typename TYPE_1>
vector <TYPE_1> RSorted (vector <TYPE_1> TEMP_A) {
    sort(TEMP_A.rbegin(), TEMP_A.rend());
    return TEMP_A;
}
template <typename TYPE_1>
deque <TYPE_1> RSorted (deque <TYPE_1> TEMP_A) {
    sort(TEMP_A.rbegin(), TEMP_A.rend());
    return TEMP_A;
}
ld Numbered (string TEMP_A) {
    ld TEMP_B;
    stringstream(TEMP_A) >> TEMP_B;
    return TEMP_B;
}
template <typename TYPE_1>
TYPE_1 Input (TYPE_1 TEMP_A) {
    get TEMP_A;
    return TEMP_A;
}
string Str (char TEMP_A) {
    string TEMP_B;
    TEMP_B = TEMP_A;
    return TEMP_B;
}

/// OTHER - Begin

/// OTHER - End

void SecondMainFunction () {

    //ios::sync_with_stdio(0);
    //cin.tie(0);

    /// Code - Begin

    ll n, y, s = 0;
    get n;
    vector <ll> a(n), b;
    for (y = 0; y < n; y++) {
        get a[y];
        s += a[y]; }
    for (y = 0; y < n; y++)
        if (a[y] == (s - a[y]) / (n - 1) && !((s - a[y]) % (n - 1)))
            b.push_back(y + 1);
    out b.size() all;
    Print(b);

    /// Code - End
}

int main () {

    //ios::sync_with_stdio(0);
    //cin.tie(0);

    ll T_NUM = 1;
    //get T_NUM;

    while (T_NUM--)
        SecondMainFunction();

    return 0;
}


/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf

using namespace std;

int main()
{
    ll n,i,j,sum=0,cc=0;
    double mean=0;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++){
        cin>>ara[i];
        sum+=ara[i];
    }
    mean=sum*1.0/n;
    for(i=0;i<n;i++){
        if(mean==ara[i]*1.0)cc++;
    }
    cout<<cc<<endl;
    for(i=0;i<n;i++){
        if(mean==ara[i]*1.0)
            cout<<i+1<<" ";
    }
    return 0;
}


/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf

using namespace std;

int main()
{
    ll n,i,j,mean=0,sum=0,cc=0;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++){
        cin>>ara[i];
        sum+=ara[i];
    }
    mean=sum/n;
    for(i=0;i<n;i++){
        if(mean==ara[i])cc++;
    }
    cout<<cc<<endl;
    for(i=0;i<n;i++){
        if(mean==ara[i])
            cout<<i+1<<" ";
    }
    return 0;
}


# include <bits/stdc++.h>

# define long           long long
# define all(vc)        vc.begin(),vc.end()
# define allr(vc)       vc.rbegin(),vc.rend()
# define pb             push_back
# define fi             first
# define se             second

using namespace std;

void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
int use[105][105];
void solve(){
    long n, m;
    cin >> n;
    vector <long> v(n), vc;
    long sum = 0;
    for(auto &i: v) cin >> i, sum += i;
    for(int i = 0; i < n; ++i)
    {
        if( v[i] == (sum - v[i]) / (n - 1) ) vc.pb(i + 1);
    }
    cout << vc.size() << '\n';
    for(auto i: vc) cout << i << ' ';
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int T = 1;
    //cin >> T;
    while( T-- ){
        solve();
        cout<<'\n';
    }

cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}


# include <bits/stdc++.h>

# define long           long long
# define all(vc)        vc.begin(),vc.end()
# define allr(vc)       vc.rbegin(),vc.rend()
# define pb             push_back
# define fi             first
# define se             second

using namespace std;

void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
int use[105][105];
void solve(){
    double n, m;
    cin >> n;
    vector < long > v(n), vc;
    double sum = 0;
    for(auto &i: v) cin >> i, sum += i;
    for(int i = 0; i < n; ++i)
    {
        if( v[i] == (sum - v[i]) / (n - 1) ) vc.pb(i + 1);
    }
    cout << vc.size() << '\n';
    for(auto i: vc) cout << i << ' ';
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int T = 1;
    //cin >> T;
    while( T-- ){
        solve();
        cout<<'\n';
    }

cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n;
     cin>>n;
     vector<int>v(n);
     vector<int>p;
     for(int i=0;i<n;i++)
     cin>>v[i];
     long long  sum=0;
     int count=0;
     for(int i=0;i<n;i++)
     {
          sum=sum+v[i];
     }
     for(int j=0;j<n;j++){
          long long  mean=(sum-v[j])/(n-1);
          if(mean==v[j])
          {

              count++;
              p.push_back(j+1);

          }

       }
       if(count)
       {
            cout<<count<<endl;
            for(int i=0;i<p.size();i++)
            cout<<p[i]<<" ";

       }
            else
            cout<<"0"<<endl;
     return 0;

}