#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, j, k, l, t;
  cin >> n;
  string str;
  cin >> str;
  long long int ans = 0, ans2 = 0;
  bool flag = 0;
  for (i = 0; i < n; i++) {
    if (str[i] != '4' && str[i] != '7') flag = 1;
    if (i < n / 2)
      ans += (str[i] - '0');
    else
      ans2 += (str[i] - '0');
  }
  if (flag || ans != ans2)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
