#include <bits/stdc++.h>
using namespace std;
using pii = pair<long long, long long>;
const long long MOD = 1e9 + 7;
const long long INF = 1 << 29;
const long long N = 1e6 + 10;
const long long MOD1 = 1073741824;
struct IOsetup {
  IOsetup() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(20);
  }
} IO;
bool lucky(string s) {
  set<char> c;
  for (auto it : s) c.insert(it);
  if ((long long)c.size() == 1) return *c.begin() == '4' || *c.begin() == '7';
  if ((long long)c.size() == 2)
    return *c.begin() == '4' && *--c.end() == '7';
  else
    return false;
}
int32_t main() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  if (!lucky(s))
    cout << "NO" << endl;
  else {
    long long sum1 = 0;
    long long sum2 = 0;
    for (long long i = 0; i < n / 2; i++) sum1 += s[i] - '0';
    for (long long i = n / 2; i < n; i++) sum2 += s[i] - '0';
    if (sum1 == sum2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
