#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const int MX = 100001;
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int sum = 0, sum2 = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != '4' && s[i] != '7') {
      cout << "NO";
      return;
    }
    if (i < n / 2) {
      sum += s[i] - 48;
    } else
      sum2 += s[i] - 48;
  }
  if (sum == sum2) {
    cout << "YES";
  } else
    cout << "NO";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  { solve(); }
  return 0;
}
